<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/26
 * Time: 21:51
 */
namespace app\admin\controller;

use app\index\model\Pay;
use think\Db;
use think\Request;

class User extends \think\Controller{
    private function getUser(){
        return new \app\admin\model\User();
    }
    private function getPay(){
        return new Pay();
    }
   /*
    * 用户分享详情
    * */
   public function shareDetail(Request $request){
       if($request->isGet()) {
       $userShareDetail= $this->getUser()->getUserInfoAndShareDetail();
       $page=$userShareDetail->render();
       $this->assign("userShareDetail",$userShareDetail);
       $this->assign("page",$page);
           return $this->fetch();
       }elseif($request->isPost()){

       }
   }

   public function shareView(Request $request){
       if($request->isGet()){
        if(is_string($request->param("openid"))){
            $userShareView=$this->getUser()->getUserShareViewByTime($request->param("openid"));
            $this->assign("userShareView",$userShareView);
            $this->assign("openid",$request->param("openid"));
            return $this->fetch();
        }
       }
   }

   /*
    * 支付选中订单
    * */
   public function payUserOrder(Request $request){
       if($request->isGet()){
         if(is_numeric($request->param("id"))){
           echo $this->getPay()->payWeiXinTX($request->param("id"));
         }
       }
   }

   /*
    * 冻结用户
    * */
   public function userLock(Request $request){
       if(is_numeric($request->param("id"))){
           return $this->getUser()->edit(['id'=>$request->param("id"),'is_lock'=>1]) ? 1 : 0;//冻结用户
       }
   }


}